function z = waston(x)
%watson function
%2=<n<=31,m=31,x0=[0,0,...,0]
%fmin1=2.28767*10^(-3) if n=6
%fmin1=1.39976*10^(-6) if n=9
%fmin1=4.72238*10^(-10) if n=12
%Author:Ji Lin
n=6;
m=31;
t=(1:29)/29;
z=ones(1,m);u=ones(1,n);v=ones(1,n);
for ii=1:29
    for jj=2:n
        u(jj)=(jj-1)*x(jj)*t(ii)^(jj-2);
    end
    for jj=1:n
        v(jj)=x(jj)*t(ii)^(jj-1);
    end
        
    z(ii)=sum(u(2:n))-sum(v(1:n))^2-1;
end
z(30)=x(1);
z(31)=x(2)-x(1)^2-1;
z=sum(z.^2);